package com.ruoyi.zsyh.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.zsyh.domain.ZsyhServiceOrderMessage;
import com.ruoyi.zsyh.service.IZsyhServiceOrderMessageService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 师傅订单消息idController
 * 
 * @author yuexl
 * @date 2022-09-06
 */
@Controller
@RequestMapping("/zsyh/serviceOrderMessage")
public class ZsyhServiceOrderMessageController extends BaseController
{
    private String prefix = "zsyh/serviceOrderMessage";

    @Autowired
    private IZsyhServiceOrderMessageService zsyhServiceOrderMessageService;

    @RequiresPermissions("zsyh:serviceOrderMessage:view")
    @GetMapping()
    public String serviceOrderMessage()
    {
        return prefix + "/serviceOrderMessage";
    }

    /**
     * 查询师傅订单消息id列表
     */
    @RequiresPermissions("zsyh:serviceOrderMessage:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ZsyhServiceOrderMessage zsyhServiceOrderMessage)
    {
        startPage();
        List<ZsyhServiceOrderMessage> list = zsyhServiceOrderMessageService.selectZsyhServiceOrderMessageList(zsyhServiceOrderMessage);
        return getDataTable(list);
    }

    /**
     * 导出师傅订单消息id列表
     */
    @RequiresPermissions("zsyh:serviceOrderMessage:export")
    @Log(title = "师傅订单消息id", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(ZsyhServiceOrderMessage zsyhServiceOrderMessage)
    {
        List<ZsyhServiceOrderMessage> list = zsyhServiceOrderMessageService.selectZsyhServiceOrderMessageList(zsyhServiceOrderMessage);
        ExcelUtil<ZsyhServiceOrderMessage> util = new ExcelUtil<ZsyhServiceOrderMessage>(ZsyhServiceOrderMessage.class);
        return util.exportExcel(list, "师傅订单消息id数据");
    }

    /**
     * 新增师傅订单消息id
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存师傅订单消息id
     */
    @RequiresPermissions("zsyh:serviceOrderMessage:add")
    @Log(title = "师傅订单消息id", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(ZsyhServiceOrderMessage zsyhServiceOrderMessage)
    {
        zsyhServiceOrderMessage.setMessageType("1");
        return toAjax(zsyhServiceOrderMessageService.insertZsyhServiceOrderMessage(zsyhServiceOrderMessage));
    }

    /**
     * 修改师傅订单消息id
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        ZsyhServiceOrderMessage zsyhServiceOrderMessage = zsyhServiceOrderMessageService.selectZsyhServiceOrderMessageById(id);
        mmap.put("zsyhServiceOrderMessage", zsyhServiceOrderMessage);
        return prefix + "/edit";
    }

    /**
     * 修改保存师傅订单消息id
     */
    @RequiresPermissions("zsyh:serviceOrderMessage:edit")
    @Log(title = "师傅订单消息id", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ZsyhServiceOrderMessage zsyhServiceOrderMessage)
    {
        return toAjax(zsyhServiceOrderMessageService.updateZsyhServiceOrderMessage(zsyhServiceOrderMessage));
    }

    /**
     * 删除师傅订单消息id
     */
    @RequiresPermissions("zsyh:serviceOrderMessage:remove")
    @Log(title = "师傅订单消息id", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(zsyhServiceOrderMessageService.deleteZsyhServiceOrderMessageByIds(ids));
    }
}
